import { createRouter, createWebHashHistory } from "vue-router";
import Login from "@/views/Login.vue";
import Home from "@/views/Home.vue"
const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/welcome",
    component: Home,
    meta: {name: '主页'},
    redirect: "/welcome/welcome",
    children: [
      {
        path: "welcome",
        key:'/welcome/welcome',
        component: () => import("@/views/index/Welcome.vue"),
        meta: {name: "欢迎页"}
      },
    ]
  },
  {
    path: "/users",
    component: Home,
    meta: {name: '用户管理'},
    redirect: "/users/users",
    children: [
      {
        path: "users",
        key:'/users/users',
        component: () => import("@/views/user/User.vue"),
        meta: {name: "用户列表"}
      },
    ]
  },
  {
    path: "/rights",
    component: Home,
    meta:{name:"权限管理"},
    redirect:'/rights/rights',
    children: [
      {
        path: "rights",
        key:'/rights/rights',
        component: () => import("@/views/power/Rights.vue"),
        meta:{name:"权限列表"}
      },
      {
        path: "roles",
        key:'/rights/roles',
        component: () => import("@/views/power/Roles.vue"),
        meta:{name:"角色列表"},
      },
    ]
  },
  {
    path: "/goods",
    component: () => import("@/views/Home.vue"),
    meta: {name: '商品管理'},
    redirect: "/goods/goods",
    children: [
      {
        path: "categories",
        key:'/goods/categories',
        component: () => import("@/views/goods/Cate.vue"),
        meta:{name:"商品分类"}
      },
      {
        path: "params",
        key:'/goods/params',
        component: () => import("@/views/goods/Params.vue"),
        meta:{name:"商品参数"}
      },
      {
        path: "goods",
        key:'/goods/goods',
        component: () => import("@/views/goods/List.vue"),
        meta:{name:"商品列表"}
      },
    ]
  },
  {
    path: "/orders",
    component: () => import("@/views/Home.vue"),
    meta:{name:"订单管理"},
    redirect: "/orders/orders",
    children: [
      {
        path:'orders',
        key:'/orders/orders',
        component: () => import("@/views/order/Orders.vue"),
        meta:{name:"订单列表"},
      }
    ]
  },



      // {
      //   path: "/goods/add",
      //   component: () => import("@/views/goods/Add.vue"),
      //   meta:{name:"商品添加"}
      // },
      // {
      //   path: "/goods/edit",
      //   component: () => import("@/views/goods/Edit.vue"),
      //   meta:{name:"商品编辑"}
      // },

];
const router = createRouter({
  routes,
  history: createWebHashHistory(),
});

//全局路由守卫
export default router;
